#include <bits/stdc++.h>

using namespace std;

void countSum(int *nums, int presum, int n)
{
    if(n <= 0)
    {
        nums[presum]++;
        return;
    }
    for(int i = 1; i <= 6; i++)
        countSum(nums, presum + i, n - 1);
}

vector<pair<int, double>> dicesSum(int n)
{
    // Write your code here
    vector<pair<int, double>> dices;
    if(n <= 0)
        return dices;
    int *nums = new int[6*n + 1];
    for(int i = n; i <= 6 * n; i++)
        nums[i] = 0;
    countSum(nums, 0, n);
    int sum = pow(6, n);
    for(int i = n; i <= 6 * n; i++)
    {
        pair<int , double> p(i, (double)nums[i] / sum);
        dices.push_back(p);
         printf("%d:\t%d\n", i, nums[i]);
    }
    return dices;
}

void print(vector<pair<int, double>> vp){
    for(int i = 0; i < vp.size(); i++)
        printf("%d, %f\t", vp[i].first, vp[i].second);
}
int main()
{
    print(dicesSum(12));
    //print(dicesSum(3));
    return 0;
}

/**
骰子求和

扔 n 个骰子，向上面的数字之和为 S。给定 Given n，请列出所有可能的 S 值及其相应的概率。
注意事项

You do not care about the accuracy of the result, we will help you to output results.
您在真实的面试中是否遇到过这个题？
样例

给定 n = 1，返回 [ [1, 0.17], [2, 0.17], [3, 0.17], [4, 0.17], [5, 0.17], [6, 0.17]]。
*/
